<template>
  <div class="main">
    <div>
      <eagle-cell-group :border="border">
        <eagle-input
          class="input_text"
          label="点检结果"
          :value="form.CheckResult == 'Y' ? '正常' : '异常'"
          readonly
        ></eagle-input>
        <eagle-input
          class="input_text"
          label="问题图片"
          :value="form.Attachs"
          readonly
        >
          <template #input>
            <eagle-image-preview :images="form.Attachs">
            </eagle-image-preview>
          </template>
        </eagle-input>
        <eagle-input
          class="input_text"
          label="问题描述"
          type="textarea"
          :value="form.CheckDesc"
          isInputText
          readonly
        ></eagle-input>
        <eagle-input
          class="input_text"
          label="整改措施"
          type="textarea"
          :value="form.CorrectiveMeasures"
          isInputText
          readonly
        ></eagle-input>
        <eagle-input
          class="input_text"
          label="整改期限"
          isInputText
          :value="form.CorrectiveDate"
          readonly
        ></eagle-input>
        <eagle-input
          class="input_text"
          label="整改责任人"
          :value="form.CorrectiveResponsibleChnName"
          readonly
        ></eagle-input>
      </eagle-cell-group>
      <eagle-cell-group
        :border="border"
        style="margin-top: 10px"
        v-if="form.CorrectiveStatus == 100"
      >
        <eagle-input
          class="input_text"
          label="整改图片"
          :value="form.CorrectiveAttachs"
          readonly
        >
          <template #input>
            <eagle-image-preview :images="form.CorrectiveAttachs">
            </eagle-image-preview>
          </template>
        </eagle-input>
        <eagle-input
          class="input_text"
          label="整改说明"
          type="textarea"
          autosize
          isInputText
          :value="form.CorrectiveDesc"
          readonly
        ></eagle-input>
      </eagle-cell-group>
      <eagle-cell-group
        :border="border"
        style="margin-top: 10px"
        v-if="form.CorrectiveStatus == 10"
      >
        <div class="block-box_item">
          <eagle-input
            class="input_text"
            rows="3"
            name="uploader"
            label="整改图片"
          >
            <template #input>
              <eagle-image-uploader :images.sync="form.CorrectiveAttachs"></eagle-image-uploader>
            </template>
          </eagle-input>
          <eagle-input
            v-model="form.CorrectiveDesc"
            rows="3"
            autosize
            label="整改说明"
            type="textarea"
            placeholder="请输入整改说明"
          ></eagle-input>
        </div>
      </eagle-cell-group>
    </div>
    <div class="btn_submit">
      <eagle-button
        block
        type="info"
        @click="submit"
        v-if="form.CorrectiveStatus == 10"
      >
        提交
      </eagle-button>
    </div>
  </div>
</template>

<script>
import { getDate } from "@/utils/getDate";
export default {
  created() {
    this.getDetail();
  },
  data() {
    return {
      filter: {
        code: this.$route.query.code,
      },
      baseUrl: process.env.VUE_APP_BASE_API,
      fileList: [],
      id: this.$route.query.id,
      code: this.$route.query.code,
      border: false,
      form: {},
    };
  },
  methods: {
    submit() {
      let params = {
        Code: this.form.Code,
        CorrectiveAttachs: this.form.CorrectiveAttachs,
        CorrectiveDesc: this.form.CorrectiveDesc,
      };
      let _this = this;
      _this.$axios
        .post("/PlanEmergencyResourceCheck/ConfirmVerify", params)
        .then((res) => {
          _this.$toast("保存成功");
          _this.loading = false;
          setTimeout(() => {
            _this.$router.goRefresh();
          }, 500);
        })
        .catch((err) => {
          console.log("err", err);
        });
    },
    getDetail() {
      let _this = this;
      _this.$axios
        .get("/PlanEmergencyResourceCheck/CheckDtsEntity", {
          params: _this.filter,
        })
        .then((res) => {
          _this.form = res.data;
          res.data.CorrectiveDate = getDate(res.data.CorrectiveDate);
        });
    },
  },
};
</script>
<style lang="less">
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 120px;
  height: 120px;
  background-color: #fff;
}
</style>
<style lang="less" scoped>
.space-between {
  justify-content: space-between;
}
</style>
